package com.mec.offload.service.impl;


import com.mec.offload.dao.OffloadSubTaskMapper;
import com.mec.offload.model.OffloadSubTask;
import com.mec.offload.service.OffloadSubTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OffloadSubTaskServiceImpl implements OffloadSubTaskService {
    @Autowired
    private OffloadSubTaskMapper offloadSubTaskMapper;
    public List<OffloadSubTask> getAllBeforeOffloadTask(){
        try {
            return offloadSubTaskMapper.getAllBeforeOffloadTask();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public List<OffloadSubTask> getAllAfterOffloadTask(){
        try {
            return offloadSubTaskMapper.getAllAfterOffloadTask();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public int addToOffloadTask(OffloadSubTask offloadSubTask){
        try {
            return offloadSubTaskMapper.addToOffloadTask(offloadSubTask);
        }catch (Exception e){
            e.printStackTrace();
            return -1;
        }
    }
    public int updateOffloadTask(OffloadSubTask offloadSubTask){
        try {
            return offloadSubTaskMapper.updateOffloadTask(offloadSubTask);
        }catch (Exception e){
            e.printStackTrace();
            return -1;
        }
    }
    public List<OffloadSubTask> getDoneOffloadTask(Integer oriTaskId){
        try {
            return offloadSubTaskMapper.getDoneOffloadTask(oriTaskId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public OffloadSubTask getOffloadTaskBySubId(Integer subTaskId){
        try {
            return  offloadSubTaskMapper.getOffloadTaskBySubId(subTaskId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    //docin
    public List<OffloadSubTask> getmecoffs(Integer offMecId,Integer page,Integer limit){
        try {
            page=(page-1)*limit;
            return  offloadSubTaskMapper.getmecoffs(offMecId,page,limit);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    public List<OffloadSubTask> getoffall(Integer page,Integer limit){
        try {
            page=(page-1)*limit;
            return  offloadSubTaskMapper.getoffall(page,limit);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public int queryAllCount(){
        return offloadSubTaskMapper.queryAllCount();
    }
    public int querymecAllCount(Integer offMecId){return offloadSubTaskMapper.querymecAllCount(offMecId);}

    @Override
    public void resetAllOffloadTasks() {
        offloadSubTaskMapper.resetAllOffloadTasks();
    }


}